export function mitt(all) {
    all = all || Object.create(null)
    return {
        on: function (type, handler) {
            (all[type] || (all[type] = [])).push(handler)
        },
        off: function (type, handler) {
            if (!all[type]) return
            all[type] = all[type].filter(h => h !== handler)
        },
        emit: function (type, evt) {
            (all[type] || []).slice().map(handler => {
                handler(evt)
            })
        }
    }
}